<?php
include_once('../lib/config.php');
require ($war_root.'/lib/verify.php');
require ($war_root.'/lib/has_char.php');
require ($war_root.'/lib/is_approved.php');
require ($war_root.'/lib/is_admin.php');


$_category = "Admin";
$_title = "";
$admin_active = 1;
$log_char = $character["character_name"];
$debug=0;

if (@$_GET ['a'] != "adding" || @$_GET ['s'] == 2) require ($war_root.'/lib/head.php');

$page = @$_GET ['p'];
$action = @$_GET ['a'];
$raid_id = @$_GET ['raid'];
$system_id = @$system ["system_id"];

/*****************************
* Start Chars part
*****************************/

$_category = "Characters";
$_title = "Approve";

$system_id = $system ["system_id"];

boxTop ( "$_category: $_title" );
echo "Newly registered, and unapproved characters will be listed here.<br>&nbsp;<br>&nbsp;<br>";


$sql = "SELECT * FROM wm_characters WHERE character_approved = 0 AND character_system_id = $system_id";
$result = $db->query($sql);
while($chars = $db->fetch_assoc ( $result )){
	if($chars['character_id'] != $_GET['id'])echo '<a href="'.$self.'?p=chars&a=a&id='.$chars['character_id'].'">Activate</a> - '.$chars['character_name']."<br>\n";
}

if(@$_GET['a'] == "a"){
	$char_id = $_GET["id"];

	$sql = "update wm_characters set character_approved='1' where character_id='$char_id'";
	$result = $db->query($sql);
	if($result == 1) echo "Character approved.<br>";
	else echo "Something went wrong approving the character. Please contact an administrator as soon as possible.";

	reprocessDKP($db, $system_id);
	echo 'Done Reprocessing DKP...<br>';

	$sql = "update wm_characters set character_active = '0' AND  where character_forum_id='$forum_id'";
	$result = $db->query($sql);

	$sql = "update wm_characters set character_active = '1' where character_id='$char_id'";
	$result = $db->query($sql);
	if($result == 1) echo "Character set active";
}



boxBot ();


require ($war_root.'/lib/foot.php');

?>